Fix reference handling in GtkScaleButton
authorMatthias Clasen <mclasen@redhat.com>
Mon, 28 Nov 2016 20:00:10 +0000 (15:00 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 28 Nov 2016 20:04:20 +0000 (15:04 -0500)
We were leaking the adjustment, since we confuse ourselves
with a property whose initial value comes out of a template.
Stop doing that.

https://bugzilla.gnome.org/show_bug.cgi?id=775212

gtk/gtkscalebutton.c
gtk/ui/gtkscalebutton.ui

index 81a689ef26fa1b8614d9c56bafe0ea5066e27375..27d668ac5eb2c337ecf9c4b4bcf9f2df4bab5989 100644 (file)
@@ -334,7 +334,6 @@ gtk_scale_button_class_init (GtkScaleButtonClass *klass)
   gtk_widget_class_bind_template_child_private (widget_class, GtkScaleButton, box);
   gtk_widget_class_bind_template_child_private (widget_class, GtkScaleButton, scale);
   gtk_widget_class_bind_template_child_private (widget_class, GtkScaleButton, image);
-  gtk_widget_class_bind_template_child_private (widget_class, GtkScaleButton, adjustment);
 
   gtk_widget_class_bind_template_callback (widget_class, cb_button_press);
   gtk_widget_class_bind_template_callback (widget_class, cb_button_release);
@@ -362,7 +361,9 @@ gtk_scale_button_init (GtkScaleButton *button)
   gtk_popover_set_relative_to (GTK_POPOVER (priv->dock), GTK_WIDGET (button));
 
   /* Need a local reference to the adjustment */
-  g_object_ref (priv->adjustment);
+  priv->adjustment = gtk_adjustment_new (0, 0, 100, 2, 20, 0);
+  g_object_ref_sink (priv->adjustment);
+  gtk_range_set_adjustment (GTK_RANGE (priv->scale), priv->adjustment);
 
   gtk_widget_add_events (GTK_WIDGET (button), GDK_SMOOTH_SCROLL_MASK);
 
index 44373ca3fb2dbc721cfcc18a84d011c1c5f3c4c6..1594d86b81b537380320415149adf60b093e93c0 100644 (file)
       </object>
     </child>
   </template>
-  <object class="GtkAdjustment" id="adjustment">
-    <property name="upper">100</property>
-    <property name="step-increment">2</property>
-    <property name="page-increment">20</property>
-  </object>
   <object class="GtkPopover" id="dock">
     <signal name="map" handler="cb_popup_mapped" swapped="no"/>
     <style>
@@ -63,7 +58,6 @@
             <property name="visible">1</property>
             <property name="can-focus">1</property>
             <property name="orientation">vertical</property>
-            <property name="adjustment">adjustment</property>
             <property name="inverted">1</property>
             <property name="round-digits">1</property>
             <property name="draw-value">0</property>